package com.qq2008.game.mojie.jdo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.Map;

/**
 * 返回类
 * @param <T>
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class R<T> {
    private int code;
    private T t;
    private Date time;
    private String nextUrl;
    private String message;
    private Map<String, Object> other;

    public static <T> R success(T t) {
        final R<T> r = new R<>();
        r.t = t;
        return r;
    }

    public static <T> R failed(String message) {
        final R<T> r = new R<>();
        r.code = -1;
        r.message = message;
        return r;
    }
}
